import request from "@/utils/request";

// 新增帖子
export function addPostApi(data: any) {
  return request({
    url: "api/posts",
    method: "post",
    data,
  });
}

// 获取帖子列表
export function getPostListApi(params: any) {
  return request({
    url: "api/posts",
    method: "get",
    params,
  });
}

// 获取单个帖子
export function getPostApi(id: any) {
  return request({
    url: `api/posts/${id}`,
    method: "get",
  });
}

// 删除帖子
export function deletePostApi(id: any) {
  return request({
    url: `api/posts/${id}`,
    method: "delete",
  });
}

// 审核通过帖子
export function approvePostApi(id: any) {
  return request({
    url: `api/posts/${id}/approve`,
    method: "put",
  });
}

// 审核拒绝帖子
export function rejectPostApi(id: any) {
  return request({
    url: `api/posts/${id}/reject`,
    method: "put",
  });
}

// 如需更新帖子（如 /api/posts/:id）
export function updatePostApi(id: any, data: any) {
  return request({
    url: `api/posts/${id}`,
    method: "put",
    data,
  });
}
